import sys
import http.client
def http_client_custom(server,os=1,port=80,filename='/',showlines=6):
    print(server,filename)
    server=http.client.HTTPConnection(server,port)
    server.putrequest('GET',filename)
    server.putheader('Accept','text/html')
    if os == 1:  # PC
        server.putheader('User-Agent',
                         'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)')
    elif os == 2:  # Android
        server.putheader('User-Agent',
                         'Mozilla/5.0(Linux; U; Android 2.2; en-gb; LG-P500 Build/FRF91) AppleWebKit/533.0 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1')
    elif os == 3:  # iOS
        server.putheader('User-Agent', 'Apple-iPhone7C2/1202.466')
    server.endheaders()
    reply=server.getresponse()
    if reply.status!=200:
        print('Error sending request!\n','status:',reply.status,'\n reason:',reply.reason)
    else:
        data=reply.readlines()
        reply.close()
        for line in data[:showlines]:print(line)
if __name__=='__main__':
    http_client_custom('www.baidu.com',os=1)